/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package com.aroundj2me.view;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import com.aroundj2me.utility.ImageLoader;

public class SplashScreen extends Canvas {
	private Display display;
    private Displayable nextDisplayable;
    private Image image;

    public SplashScreen(Display display, Displayable nextDisplayable) {
    	this.display = display;
    	this.nextDisplayable = nextDisplayable;
    	image = ImageLoader.getImage(ImageLoader.SPLASH_SCREEN);
    }
    
    public void dismiss() {
    	display.setCurrent(nextDisplayable);
    }
    
	protected void paint(Graphics graphics) {
		int width = getWidth();
        int height = getHeight();
        graphics.drawImage(image, width/2, height/2, Graphics.VCENTER | Graphics.HCENTER);
	}
}
